<template>
  <el-row type="flex" justify="space-between" align="middle" style="height: 40px; width: 100%">
    <el-col>
      <strong v-if="isFull"><i class="el-icon-s-home" /> {{ nodeData.name }}</strong>
      <span v-else>{{ nodeData.name }}</span>
      <!-- <p>{{ showNode() }}</p> -->
    </el-col>
    <el-col :span="4">
      <el-row type="flex" justify="end">
        <!-- 两个内容 -->
        <el-col>{{ nodeData.manager }}</el-col>
        <el-col>
          <!-- 下拉菜单 element -->
          <el-dropdown trigger="click">
            <span class="pointer">
              操作<i class="el-icon-arrow-down" />
            </span>
            <!-- 下拉菜单 -->
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item :data-index="nodeData" @click.native="addDepartments(nodeData)">添加子部门</el-dropdown-item>
              <el-dropdown-item v-if="!isFull " @click.native="editDepartments(nodeData)">编辑部门</el-dropdown-item>
              <el-dropdown-item v-if="!isFull " @click.native="remove(nodeData.id)">删除部门</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-col>
      </el-row>
    </el-col>
  </el-row>
</template>

<script>
export default {
  props: {
    nodeData: {
      type: Object,
      required: true
    },
    isFull: {
      type: Boolean,
      require: true
    }
  },
  methods: {
    // showNode() {
    //   console.log(this.nodeData)
    // },
    // 删除部门
    remove(id) {
      this.$emit('removed', id)
    },
    // 新增部门
    addDepartments(item) {
      this.$emit('add', item)
    },
    // 编辑部门
    editDepartments(nodeData) {
      this.$emit('editDepts', nodeData)
    }
  }
}
</script>

<style scoped>
.pointer {
  cursor: pointer;
}
</style>
